package com.ruoyi.durian.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.durian.domain.LlMap;
import com.ruoyi.durian.domain.LlSearchHistory;
import com.ruoyi.durian.domain.dto.SearchHistoryDto;
import com.ruoyi.durian.service.LlMapService;
import com.ruoyi.durian.service.LlSearchHistoryService;
import com.ruoyi.durian.mapper.LlSearchHistoryMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author lenovo
* @description 针对表【ll_search_history(订单模块-搜索历史记录)】的数据库操作Service实现
* @createDate 2024-07-26 16:17:15
*/
@Service
public class LlSearchHistoryServiceImpl extends ServiceImpl<LlSearchHistoryMapper, LlSearchHistory>
    implements LlSearchHistoryService{

    @Resource
    private LlSearchHistoryMapper llSearchHistoryMapper;

    @Resource
    private LlMapService llMapService;

    /**
     * 历史搜索记录
     *
     * @return
     */
    @Override
    public List<SearchHistoryDto> searchHistory() {
        Integer userId = 1204;
        return llSearchHistoryMapper.selectsearchHistory(userId);
    }

    /**
     * 搜索
     * @param name
     * @return
     */
    @Override
    public List<LlMap> searchLike(String name) {
        LambdaQueryWrapper<LlMap> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(LlMap::getName,name)
                .or(wrapper1 -> wrapper1.like(LlMap::getAddress,name));
        List<LlMap> list = llMapService.list(wrapper);
        return list;
    }



}




